home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / PERCENTT.DMO < prev    next >
Text File  |  1996-07-04  |  4KB  |  80 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   PERCENTT.DMO ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16. $endif
  17.  
  18. '.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
  19. ' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
  20.  
  21. $INCLUDE "DAS-NB01.INC"
  22. $INCLUDE "DAS-NBT1.INC"
  23. COLOR 7, 0
  24. CLS
  25. ? "┌───────────────────────────────────────────────────────────────────────
  26. ? "│ PerCentBarT ( Row?, Col?, Done&, Total&, Attr? )
  27. ? "├───────────────────────────────────────────────────────────────────────
  28. ? "│ Here's one to play with. It will have to be mushed around to make it
  29. ? "│ work intelligently in your programs but it's short and should pose
  30. ? "│ no problems. I've put both the bar and the whirly-gig in the same
  31. ? "│ routine but I usually use only one or the other and sometimes I print
  32. ? "│ the actual percentage on the screen under the bar; it just depends on
  33. ? "│ the program.
  34. ? "└───────────────────────────────────────────────────────────────────────
  35.  
  36. MakeTBox 13, 10, 5, 30, 1, 31, 21, 7, 0, ""
  37. TprintCENTER 14, 11, 28, "Percentage Bar", 30
  38. TBoxFILL 16, 12, 1, 25, 32, 112
  39.  
  40. MaxNumber% = 200
  41.  
  42. FOR Done% = 1 TO MaxNumber%
  43.   SetDELAY 24
  44.   PerCentBarT 16, 12, Done%, MaxNumber%, 116
  45.   EndDELAY
  46.   IF INSTAT THEN EXIT FOR
  47. NEXT
  48.  
  49. ' ────────────────────────────────────────────────────────────────────────
  50. ' ─────────── everything below here can be put into a .PBU ───────────────
  51. ' ────────────────────────────────────────────────────────────────────────
  52.  
  53.   DECLARE SUB Tprint (BYVAL Row?,BYVAL Col?,BYVAL V$,BYVAL Attr?)
  54.  
  55. '.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
  56. ' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
  57. ' PURPOSE: print a per-centage bar and whirly-gig on the screen
  58. '  PARAMS: Row?    row for %bar
  59. '          Col?    starting column ( 26 columns used )
  60. '          Done&   number of items "done"
  61. '          Total&  total number of items
  62. '          Attr?   color attribute
  63. '.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
  64. ' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
  65. SUB PerCentBarT (BYVAL Row?,BYVAL Col?,BYVAL Done&,BYVAL Total&,BYVAL Attr?) LOCAL PUBLIC
  66.   STATIC C%
  67.   LOCAL  D$, L%, W%
  68.                                                        '┌────────────────────
  69.   INCR C%, 1 : IF C% > 4 THEN C% = 1                   '│ 4 part whirly-gig
  70.   Tprint Row?, Col? + 25, MID$( "\|/─", C%, 1 ), Attr? '│ print it!
  71.                                                        '├────────────────────
  72.   L% = CINT( 50 * ( Done& / Total& ) )                 '│ 25 chars of the
  73.   W% = ( L% MOD 2 )                                    '│ bar but using "▌"
  74.   L% = ( L% \ 2 )                                      '│ to increase it to
  75.   IF L% > 0 THEN D$ = STRING$( L%, 219 )               '│ a total of 50.
  76.   IF W% > 0 THEN D$ = D$ + MID$( "▌", W%, 1 )          '│
  77.   Tprint Row?, Col?, D$, Attr?                         '│
  78.                                                        '└────────────────────
  79. END SUB
  80.